
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v-on="http://www.w3.org/1999/xhtml"
      xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <meta http-equiv="pragma" content="no-cache" />
    <meta http-equiv="content-type" content="no-cache, must-revalidate" />
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT"/>
    <title>个人信息</title>

    <link href="../css/bootstrap.css" rel="stylesheet"/>
    <link href="../css/font-awesome.css" rel="stylesheet"/>
    <link href="../css/custom-styles.css" rel="stylesheet"/>
    <link href="../css/element/index.css" rel="stylesheet"/>

    <style>
        [v-cloak] {
            display: none;
        }
        .table th, .table td {
            text-align: center !important;
            vertical-align: middle !important;
        }
    </style>
</head>
<body>
<div id="wrapper" v-cloak>
    <div class="row">
        <div class="col-md-12" style="height:60px;">
            <nav class="navbar navbar-default top-navbar" role="navigation">
                <div class="row">
                    <div class="col-md-2">
                        <a class="navbar-brand" style="width:100%; background-color: darkslateblue"><strong style="font-size: 20px;">学生选课管理系统</strong></a>
                    </div>
                    <div class="col-md-10">

                        <ul class="nav navbar-top-links navbar-right">
                            <li style="color: white">欢迎您，{{ user.name }}</li>
                            <li class="dropdown">
                                <a class="dropdown-toggle" data-toggle="dropdown" href="#" aria-expanded="false">
                                    <i class="fa fa-user fa-fw"></i> <i class="fa fa-caret-down"></i>
                                </a>
                                <ul class="dropdown-menu dropdown-user">
                                    <li><a href="javascript:void(0)" @click="personalPage"><i class="fa fa-user fa-fw"></i> 个人信息</a>
                                    </li>
                                    <li class="divider"></li>
                                    <li><a href="javascript:void(0)" @click="logout"><i class="fa fa-sign-out fa-fw"></i> 退出</a>
                                    </li>
                                </ul>
                            </li>
                        </ul>
                    </div>
                </div>
            </nav>
        </div>
    </div>
    <div class="row">
        <div class="col-md-2">
            <nav id="nav-id" class="navbar-default navbar-side" role="navigation">
                <div class="sidebar-collapse">
                    <ul class="nav" id="main-menu">

                        <li>
                            <a href="#"><i class="fa fa-sitemap"></i> 信息管理<span class="fa arrow"></span></a>
                            <ul class="nav nav-second-level collapse in">
								<li v-if="user.level === 1">
									<a href="adminInfo.html"><i class="fa fa-table sub-icon-mg" aria-hidden="true"></i><span class="mini-sub-pro">管理员信息</span></a>
								</li>
								<li v-if="user.level === 1">
									<a href="teacherInfo.html"><i class="fa fa-table sub-icon-mg" aria-hidden="true"></i><span class="mini-sub-pro">教师信息</span></a>
								</li>
								<li v-if="user.level === 1">
									<a href="studentInfo.html"><i class="fa fa-table sub-icon-mg" aria-hidden="true"></i><span class="mini-sub-pro">学生信息</span></a>
								</li>
								<li v-if="user.level === 1">
									<a href="xueyuanInfo.html"><i class="fa fa-table sub-icon-mg" aria-hidden="true"></i><span class="mini-sub-pro">学院信息</span></a>
								</li>
								<li v-if="user.level === 1">
									<a href="zhuanyeInfo.html"><i class="fa fa-table sub-icon-mg" aria-hidden="true"></i><span class="mini-sub-pro">专业信息</span></a>
								</li>
								<li>
									<a href="classInfo.html"><i class="fa fa-table sub-icon-mg" aria-hidden="true"></i><span class="mini-sub-pro">课程信息</span></a>
								</li>

								<li>
									<a href="xuankeInfo.html"><i class="fa fa-table sub-icon-mg" aria-hidden="true"></i><span class="mini-sub-pro">选课信息</span></a>
								</li>


                                <li>
                                    <a href="javascript:void(0)" @click="personalPage" class="active-menu"><i class="fa fa-user"></i>个人信息</a>
                                </li>

                            </ul>
                        </li>

                        <li>
                            <a href="updatePassword.html"><i class="fa fa-unlock-alt"></i>修改密码</a>
                        </li>
                        <li>
                            <a href="javascript:void(0)" @click="logout"><i class="fa fa-power-off"></i>退出登录</a>
                        </li>
                    </ul>
                </div>
            </nav>
        </div>
        <div class="col-md-10" style="background-color: #e6e6e6">
            <div id="page-wrapper">
                <div id="page-inner">
                    <div class="row">
                        <div class="col-md-12">
                            <div class="panel panel-default" style="background-color: whitesmoke">
                                <div class="panel-heading" style="margin-bottom:10px; background-color: whitesmoke">
                                    个人信息
                                </div>
                                <div class="panel-body">
                                    <form class="form-horizontal">
                                        <input type="hidden" v-model="entity.id">
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">姓名</label>
                                            <div class="col-sm-7">
                                                <input type="text" class="form-control" v-model="entity.name" placeholder="请输入姓名">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">性别</label>
                                            <div class="col-sm-7">
                                                <label class="radio-inline">
                                                    <input type="radio" value="男" v-model="entity.sex">男
                                                </label>
                                                <label class="radio-inline">
                                                    <input type="radio" value="女" v-model="entity.sex">女
                                                </label>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">年龄</label>
                                            <div class="col-sm-7">
                                                <input type="text" class="form-control" v-model="entity.age" placeholder="请输入年龄">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">学号</label>
                                            <div class="col-sm-7">
                                                <input type="text" class="form-control" v-model="entity.code" placeholder="请输入学号">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">总学分</label>
                                            <div class="col-sm-7">
                                                <input disabled type="text" class="form-control" v-model="entity.score">
                                            </div>
                                        </div>
                                    </form>
                                    <div style="text-align: center">
                                        <button class="btn btn-primary" @click="update()">保存</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="../js/jquery-1.10.2.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/jquery.metisMenu.js"></script>
<script src="../js/custom-scripts.js"></script>
<script src="../js/my.js"></script>
<script src="../js/vue2.6.11/vue.min.js"></script>
<script src="../js/vue2.6.11/axios.js"></script>
<script src="../js/element/index.js"></script>

<script>
    function msg(type, msg) {
        Vue.prototype.$message({
            type: type, // success（成功）、warning（警告）, error(错误)
            message: msg,
            duration: 2000,
            offset: 100,
            center: true
        })
    }
    new Vue({
        el: '#wrapper',
        data: {
            user: {},
            entity: {},
        },
        created: function () {
            const menuHeight = document.getElementById("main-menu").getElementsByTagName('li').length * 53;
            const bodyHeight = document.getElementsByTagName("body")[0].clientHeight;
            document.getElementById("nav-id").style.height = (menuHeight > bodyHeight ? menuHeight : bodyHeight) + 'px';

            this.user = JSON.parse(localStorage.getItem('user'));
            this.loadData();

            // TODO

        },
        methods: {
            loadData() {
                axios.get("/getUser").then(res => {
                    if (res.data.code === '0') {
                        this.entity = res.data.data;
                    } else {
                        msg("error", res.data.msg);
                    }
                })
            },
            update() {
                axios.put("/studentInfo", this.entity).then(res => {
                    if (res.data.code === '0') {
                        msg("success", "保存成功");
                    } else {
                        msg("error", res.data.msg);
                    }
                })
            },
            logout() {
                logout();
            }
        }
    })
</script>
</body>
</html>